Page({
  data: {
    isLogin: false,
    userInfo: {
      name: '',
      phone: ''
    },
    avatarUrl: '',
    orderIcons: [
      '/images/icons1/A.png',
      '/images/icons1/B.png',
      '/images/icons1/C.png',
      '/images/icons1/D.png'
    ],
    systemIcons: [
      '/images/icons1/1.png',
      '/images/icons1/2.png',
      '/images/icons1/3.png',
      '/images/icons1/4.png',
      '/images/icons1/5.png',
      '/images/icons1/6.png',
      '/images/icons1/7.png',
      '/images/icons1/8.png'
    ]
  },
  onGetUserInfo: function(e) {
    if (e.detail.userInfo) {
      this.setData({
        isLogin: true,
        userInfo: {
          name: e.detail.userInfo.nickName,
          phone: '1234567890'
        },
        avatarUrl: e.detail.userInfo.avatarUrl
      });
    }
  },
  onLogout: function() {
    this.setData({
      isLogin: false,
      userInfo: {
        name: '',
        phone: ''
      },
      avatarUrl: ''
    });
  },
  onOrderTap: function(e) {
    const status = e.currentTarget.dataset.status;
    let url = '';
    switch (status) {
      case '待付款':
        url = '/pages/order-pending/order-pending'; // 确保这是正确的页面路径
        break;
      case '待接单':
        url = '/pages/order-waiting/order-waiting'; // 确保这是正确的页面路径
        break;
      case '已取消':
        url = '/pages/order-cancelled/order-cancelled'; // 确保这是正确的页面路径
        break;
      case '已完成':
        url = '/pages/order-completed/order-completed'; // 确保这是正确的页面路径
        break;
    }
    if (url) {
      wx.navigateTo({
        url: url
      });
    }
  },
  onSystemTap: function(e) {
    const url = e.currentTarget.dataset.url;
    if (url) {
      wx.navigateTo({
        url: url
      });
    }
  }
});